<?php

class Product extends Controller {
	
	public $useDB = array("Product", "Category");
	
	public function show($id) {
		if($product = $this->dbProduct->get($id)){
			$this->set("product", $product);
		}
	}
	
	public function discount($page=1) {
		$conditions = array("discount"=>1);
		
		$this->set("total", $this->dbProduct->count(array(
			"conditions" => $conditions
		)));
		
		$p = $this->dbProduct->findWithImage(array(
			"conditions" => $conditions,
			"offset" => array($page, PRODUCTS_PER_PAGE)
		));
		
		$this->set("products", $p);
		$this->set("page", $page);
	}
	
}